package com.lkcg.demo.service.impl;

import com.lkcg.demo.config.auditor.UserIDAuditorConfig;
import com.lkcg.demo.dao.MyTestDAO;
import com.lkcg.demo.model.MyTest;
import com.lkcg.demo.service.MyTestService;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;

@Service
@Log4j
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON, proxyMode = ScopedProxyMode.INTERFACES)
public class MyTestServiceImpl implements MyTestService {
    @Autowired
    private MyTestDAO myTestDAO;
    @Autowired
    private UserIDAuditorConfig userIDAuditorConfig;

    @Override
    public MyTest casInsertTest() {
        userIDAuditorConfig.setCurrentAuditor("1");
        // myTestDAO.inser
        // MyTest myTest = myTestDAO.selectByPrimaryKey("1");
        MyTest myTest = new MyTest();
        myTest.setName("1231");
        myTest.setName2("1231");
        myTestDAO.insertSelective(myTest);
        log.info(myTest.toString());
        MyTest meTest = myTestDAO.selectByPrimaryKey("1");
        meTest.setName("213");
        myTestDAO.updateByPrimaryKey(meTest);

        return myTest;
    }
}
